<template>
  <el-dialog
    title="查验结果"
    :modal="false"
    :visible.sync="centerDialogVisible"
    width="50%"
    center
  >
    <div>
      <el-row :gutter="6">
        <el-form
          ref="paramForm"
          :model="paramData"
          size="mini"
          label-width="280px"
        >
          <el-row>
            <el-col :span="14">
              <el-form-item label="查验件数" prop="examinePackages">
                <el-input
                  v-model="paramData.examinePackages"
                  placeholder="请输入查验件数"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="14">
              <el-form-item label="查验结果" prop="examineResult">
                <el-select
                  v-model="paramData.examineResult"
                  placeholder="请输入查验结果"
                  clearable
                  filterable
                  :style="{ width: '100%' }"
                >
                  <el-option
                    v-for="(k, v) in examineResultOptions"
                    :key="k"
                    :label="examineResultOptions[v]"
                    :value="parseInt(v)"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="14">
              <el-form-item label="查验备注" prop="examineRemark">
                <el-input
                  v-model="paramData.examineRemark"
                  placeholder="请输查验备注"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </el-row>
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button @click="centerDialogVisible = false">取 消</el-button>
      <el-button
        type="primary"
        @click="updateExamineResult"
        v-loading.fullscreen.lock="fullscreenLoading"
        >确 定</el-button
      >
    </span>
  </el-dialog>
</template>

<script>
import { ajax } from "@/store/yg/common/utils";
import axios from "axios";
import * as constant from "@/store/yg/common/constant";
import { m } from "@/store/yg/common/local";
export default {
  props: ["row", "data", "more"],
  data() {
    return {
      fullscreenLoading: false,
      centerDialogVisible: false,
      paramData: {
        id: 0,
        examinePackages: "",
        examineResult: "",
        examineRemark: ""
      },
      examineResultOptions: {
        1: "相符",
        2: "数量不符",
        3: "品牌不符",
        4: "少报漏报",
        5: "瞒报漏报"
      }
    };
  },

  methods: {
    //修改派送仓库地址
    updateExamineResult() {
      var param = {};
      param["id"] = this.data["id"];
      param["fba"] = 0;
      param["examinePackages"] = this.paramData.examinePackages;
      param["examineResult"] = this.paramData.examineResult;
      param["examineRemark"] = this.paramData.examineRemark;
      this.fullscreenLoading = true;
      ajax("updateExamineResult", param).then(
        res => {
          this.fullscreenLoading = false;
          if (res.code != 200) {
            if (null != res.message) {
              this.$message.error(m(res.message));
            } else {
              this.$message.error("修改失败!");
            }
          } else {
            this.$message.success("修改成功!");
            this.centerDialogVisible = false;
          }
        },
        error => {
          console.log(error);
        }
      );
    }
  },
  mounted() {
    this.paramData.examinePackages = this.data["examinePackages"];
    this.paramData.examineResult = this.data["examineResult"];
    this.paramData.examineRemark = this.data["examineRemark"];
  }
};
</script>

<style></style>
